<?php

class WidgetFormFilterChoice extends sfWidgetFormChoiceBase
{

	public function configure($options = array(), $attributes = array())
	{
		parent::configure($options, $attributes);
	}

	public function render($name, $value = null, $attributes = array(), $errors = array())
	{
		$options = array();
		
		$options[] = $this->renderContentTag('option', '', array('value' => ''));

		foreach($this->getOption('choices') as $key => $choice)
		{
			$attributes = array();
			$attributes['value'] = $key;
			if(is_array($value) && $key == $value['text'])
				$attributes['selected'] = 'selected';
			$options[] = $this->renderContentTag('option', $choice, $attributes);
		}
		
		$attributes['name'] = $name . '[text]';
		return $this->renderContentTag('select', "\n" . implode("\n", $options) . "\n", $attributes);
	}

}
